
SET QUOTED_IDENTIFIER ON
GO

SET ANSI_NULLS ON
GO

IF EXISTS (SELECT * FROM sys.objects WHERE [object_id] = OBJECT_ID(N'[dbo].[fn_GetDayValue]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
    DROP FUNCTION [dbo].[fn_GetDayValue];
GO
CREATE FUNCTION [dbo].[fn_GetDayValue]
(
    @DateTime datetime
)
returns int
with schemabinding
as
begin

return datepart(year, @DateTime)*10000 + datepart(month, @DateTime) * 100 + datepart(day, @DateTime);
end
GO